package com.qf.flash.mvp.presenter;

import com.qf.dblib.dao.impl.UserMgr;
import com.qf.flash.http.HttpManager;
import com.qf.flash.model.CommentBean;
import com.qf.flash.mvp.contract.CommentContract;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseResponse;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.util.RxUtils;

import java.util.List;

/**
 * 描述: 评论列表
 * 2020/3/24 14:20
 */
public class CommentPresenter extends BasePresenter<CommentContract.View> implements CommentContract.Presenter {

    @Override
    public void getCommentData(String playId,int page) {
        String uid = UserMgr.getInstance().getLoginUser().getUid();
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .COMMENT_LIST(uid, playId, page)
                .compose(RxUtils.handleBaseResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<BaseResponse<List<CommentBean>>>(mRootView, false) {
                    @Override
                    public void onSuccess(BaseResponse<List<CommentBean>> response) {
                        mRootView.setCommentData(response.getData(), response.getTotalPage());
                    }
                })
        );
    }
}
